package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Name     string `gorm:"type:varchar(20);not null;comment:'用户名'"`
	Phone    string `gorm:"type:char(11);not null;comment:'手机号'"`
	Password string `gorm:"type:char(32);not null;comment:'密码'"`
}

func (u *User) Find(phone string) error {
	err := DB.Debug().Where("phone =?", phone).Find(&u).Error
	return err
}

func (u *User) Created() error {
	err := DB.Debug().Create(&u).Error
	return err
}
